﻿@model IEnumerable<Chilis.Caja.Data.Models.Caja>
 
@{
    ViewBag.Title = "Actualizar Caja";
   
    Layout = "~/Views/Shared/_Layout.cshtml";
}


<script language="javascript1.1"> 
function jsSubmit() {
   



   if (document.frmActualizar.txtDescaja.value==''){
			alert('Ingrese la descripción de la caja');
			document.frmActualizar.txtDescaja.focus();
			return false;
			}    if (document.frmActualizar.cajero.value==''){
			alert('Seleccione Cajero');
			document.frmActualizar.cajero.focus();
			return false;
			}
    if (document.frmActualizar.turno.value==''){
			alert('Seleccione turno');
			document.frmActualizar.turno.focus();
			return false;
			}            var r=confirm('¿Esta seguro de realizar los cambios?');
            if (r==true)    {
                document.frmActualizar.submit();
            }else{
                    return false;
                }
	   
	}
        function jsCancelar() {

      window.location.href = "/Caja/ListCajas?buscar=TODO";
    }


</script> 

 <h1>Actualizar Caja </h1>

     @using (Html.BeginForm("ActualizarCaja", "Caja", FormMethod.Post, new { name = "frmActualizar", id = "frmActualizar", @class = "well" }))         
       {      
 
    <table> 



      @{
                            foreach (Chilis.Caja.Data.Models.Caja oCaja in Model)
                            {  
                            <tr>
                                
                              <td>Codigo Caja </td>
                              <td> <input id="txtidcaja" name="txtidcaja" type="text" readonly="readonly" value=@oCaja.IdCaja /></td>     
                              </tr> 
                               
                            <tr>
                              <td>Descripción Caja</td>
                              <td> <input id="txtDescaja" name="txtDescaja" type="text" value=@oCaja.NombreCaja /></td>      
                                       
                            </tr>
                            }
                        }

   <tr>
<td><label for="cajeros">Cajero:</label></td>
<td>@Html.DropDownList("cajero", (SelectList)ViewBag.Cajeros, "--Select cajero--")</td>
        </tr>

         <tr>
<td><label for="turnos">Turno:</label></td>
<td>@Html.DropDownList("turno", (SelectList)ViewBag.Turnos, "--Select turno--")</td>
        </tr>
         
        @Html.Hidden("caj", (string)ViewBag.CampoA)
        @Html.Hidden("tur", (string)ViewBag.CampoB)

 </table> 
          
          <br />   
         <br /> 
           
      <button type="button" class="button aceptar" onclick="jsSubmit()">
          Grabar
       </button>   
             
         
         
               <button type="button" class="button cancelar" onclick="jsCancelar()">
          Cancelar
       </button>                 
           <script language="JavaScript">

             //  alert("Holass" + document.frmActualizar.casa.value);            
                  // document.frmActualizar.cajero.selected = document.frmActualizar.casa.value;
               //Get select object
             
               //Set selected
               setSelectedValue(cajero, document.frmActualizar.caj.value);
               setSelectedValue(turno, document.frmActualizar.tur.value);

               function setSelectedValue(selectObj, valueToSet) {
                   for (var i = 0; i < selectObj.options.length; i++) {
                       if (selectObj.options[i].text == valueToSet) {
                           selectObj.options[i].selected = true;
                           return;
                       }
                   }
               }

   
          </script>
       }
